import http from '/@lib/utils/http/request'
import { DeptForm, DeptQuery, DeptVO } from '/@/api/system/dept/types.ts'

export const ApiSysDept: any = {}

/**
 * 查询客户端管理列表
 */
ApiSysDept.list = (queryParam?: DeptQuery): Promise<DeptVO[]> => {
  return http.get('/sysDept/list', queryParam)
}

/**
 * 查询客户端管理详细
 * @param id
 */
ApiSysDept.getInfo = (id: string | number): Promise<DeptVO> => {
  return http.get('/sysDept/getInfo/' + id)
}

/**
 * 新增客户端管理
 * @param data
 */
ApiSysDept.save = (data: DeptForm) => {
  return http.post('/sysDept/save', data)
}

/**
 * 修改客户端管理
 * @param data
 */
ApiSysDept.update = (data: DeptForm) => {
  return http.post('/sysDept/update', data)
}

/**
 * 删除客户端管理
 * @param id
 */
ApiSysDept.remove = (id: string | number | Array<string | number>) => {
  return http.post('/sysDept/remove/' + id)
}

/**
 * 状态修改
 * @param id ID
 * @param status 状态
 */
ApiSysDept.changeStatus = (id: number | string, status: string) => {
  const data = {
    id,
    status
  }
  return http.post('/system/dept', data)
}

// 查询部门下拉树结构
ApiSysDept.treeSelect = (): Promise<DeptVO[]> => {
  return http.get('/sysDept/treeSelect')
}

/** 获取未被禁用的部门树列表 */
ApiSysDept.tree = (): Promise<DeptVO[]> => {
  return http.get('/sysDept/tree')
}
